/*
 * ImageLayerMerger.h
 *
 *  Created on: 2010-9-19
 *      Author: try
 */

#ifndef IMAGELAYERMERGER_H_
#define IMAGELAYERMERGER_H_
#include "../draw/LayerMerger.h"
#include "gdiplus_commons.h"

namespace Ed {
  class DrawPage;
  class Layer;

  /**
   * 采用Gdiplus的Gdiplus::Bitmap来进行图层合并，支持Alpha混合
   */
  class ImageLayerMerger : public LayerMerger {
    public:
      ImageLayerMerger(DrawPage* page);
      virtual ~ImageLayerMerger();

      /**
       * 将图层与目标设备合并
       */
      virtual bool merge();

    private:
      DrawPage* page;

      struct BufferItem{
         Gdiplus::Bitmap* bitmap;
         Gdiplus::Graphics* graphics;
      };
      typedef hash_map<long, BufferItem*> LayerBufferMap;
      LayerBufferMap layerBufferMap;


      /**
       * 返回BufferItem
       */
      BufferItem* getBufferItem(Layer* l);
  };

}

#endif /* IMAGELAYERMERGER_H_ */
